<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="gbck" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<gbck:page title="欢迎" enableAjaxFileUpload="true">

    <jsp:attribute name="script">
        <script type="application/javascript">
            $(function () {
                AjaxFile.upload("#demoFile", function (e, data) {
                    console.log(data.result);

                    $("#demoImg").attr("src", data.result.url).data("file", data.result.file);
                });
                $("body").on("click", ".fa-download", function () {
                    AjaxFile.download($("#demoImg").data("file"))
                });
            })
        </script>
    </jsp:attribute>
    <jsp:body>

        <img id="demoImg" src="" alt="Demo File">
        <i class="fa fa-download"></i>
        <input type="file" id="demoFile" name="file">
    </jsp:body>
</gbck:page>
